package com.quanyan.stadium.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;

/**
 * Created by xiaoxiao on 16/9/14.
 *
 * 对战表生成的时候利用aop逻辑来拆分业务
 */
@Aspect
@Configuration
public class GompListCreateAspect {


    private static final Logger logger = LoggerFactory.getLogger(GompListCreateAspect.class);


    /**
     *
     * 监控俱乐部赛事的创建(对createGameEvent方法进行切面)
     * */
    @Pointcut("execution(* com.quanyan.stadium.service.gameRules.impl.GameRoundServiceImpl.generateCompList(..))")
    public void generateCompList() {}


    /**
     *  对战表生成之前,一些简单的操作
     *
     * */
    @Before(value="generateCompList()")
    public void doBefore(JoinPoint jp) {

    }



    /**
     *  俱乐部赛事创建完成,触发相应的操作
     *
     *
     * */
    @AfterReturning(value="generateCompList()", returning = "rtv")
    public void doAfter(JoinPoint jp, Object rtv) throws Throwable{

        logger.info("俱乐部创建赛事成功,开始缓存赛事信息.赛事ID{}", 1);
    }

}
